<template>
    <div class="downBox">
            <h2>白嫖游戏搜索</h2>
            <!-- <span style="color:hotpink;font-size:14px">本软件使用B站登录的cookie认证身份，不否认同一时间大量下载会被封禁</span> -->
            <div class="downBoxc">
                <input class="input" type="text" v-model="input" placeholder="请输入游戏名">
                <button class="but blueB" @click="getM()">搜索</button>
            </div>

    </div>
</template>
<script setup>
import { error } from "console";
import { ref } from "vue";
const https = require('https');
const cheerio = require("cheerio");
const iconv = require("iconv-lite");

const input = ref('')
const AurlList = ref([])
const tip = ref('')

function getM(){
    https.get('https://www.flysheep6.com/?s='+input.value+'',(res)=>{
        let data = ''
        res.setEncoding('utf8');
        res.on('data',(chunk)=>{
            data += chunk
        })
        res.on('end',()=>{
            // var chunk = iconv.decode(Buffer.concat(data), 'gbk');
            // var htmlListData = filterHtmlList(chunk);
            
            let $ = cheerio.load(data)
            let Aurl = $('#blog .container .row .content-wrapper .row')
            // dmToken.value = JSON.parse(data).data.token
            
            if(Aurl.length != 0){
                // console.log(Aurl[0].children[0].children[1].children[1].children[1].children[1].attribs.href)
                Aurl[0].children.forEach(element => {
                    AurlList.value.push({aurl:element.children[1].children[1].children[1].children[1].attribs.href,
                    title:element.children[1].children[1].children[1].children[5].children[1].children[0].data})
                });
            }else{
                tip.value = '没有找到'
            }
            console.log(AurlList.value)
        })
    }).on('error', function () {
        console.log('获取数据出错！',error);
    });
}

</script>
<style scoped>
.downBox{
    text-align: center;
    color: #fff;
    font-size: 20px;
    height: 100%;
    overflow: auto;
}
.downBoxc{
    width:100%;
    display: flex;
    justify-content: center;
}
.but{
    border-radius: 2px;
    border: none;
    padding: 3px 20px;
    font-family: myFont;
    margin-right: 10px;
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(var(--def-filler));
}
.input{
    border-radius: 2px;
    background-color: var(--def-box-color);
    backdrop-filter: blur(var(--def-filler));
    color: #fff;
    font-family: myFont;
    font-size: 16px;
    padding: 10px 15px;
    outline: none;
    border: none;
    width: 70%;
    margin-right: 10px;
}
.blueB{
    background-color: var(--def-button-color-blue);
}



/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
.downBox::-webkit-scrollbar,.LiveList::-webkit-scrollbar  {
    width: 0px;
    height: 6px
}
/*定义滚动条轨道*/
.downBox::-webkit-scrollbar-track,.LiveList::-webkit-scrollbar-track {
    background-color: transparent;
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0
}
/*定义滑块 内阴影+圆角*/
.downBox::-webkit-scrollbar-thumb,.LiveList::-webkit-scrollbar-thumb {
    background-color: #30B07F00;
    background-image: -webkit-linear-gradient(45deg,rgba(255,255,255,0) 100%,transparent 100%,transparent 50%,rgba(255,255,255,0) 50%,rgba(255,255,255,0) 75%,transparent 75%,transparent);
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0
}
</style>